package com.woniuxy.aop.service.impl;

import com.woniuxy.aop.bean.Manager;
import com.woniuxy.aop.mapper.ManagerMapper;
import com.woniuxy.aop.service.IManagerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author linke
 * @version 1.0
 * @className: ManagerServiceImpl
 * @description: 管理员服务层的实例
 * @date 2021/11/13 11:43
 *
 * @Service注解 将IMenuService接口的实例交给spring容器管理
 * @Transactional 只读事务声明，用于对查询事务的优化
 */
@Transactional(readOnly = true)
@Service
public class ManagerServiceImpl implements IManagerService {
    /**
     *注入管理员持久层的实例
     */
    @Resource
    private ManagerMapper managerMapper;


    @Override
    public List<Manager> findAll() {
        return managerMapper.findAll();
    }

    //REPEATABLE_READ可重复读取级别    在执行修改操作提交后，只允许查询
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void saveManager(Manager manager) {

     managerMapper.saveManager(manager);

    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void updateManager(Manager manager) {

        managerMapper.updateManager(manager);
    }

    @Override
    public Manager getOneById(Integer id) {
        return managerMapper.getOneById(id);
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public void deleteManager(Integer id) {
        managerMapper.deleteManager(id);
    }
}
